//package com.uam.core.business.help;
//package cn.itbox.gis.common.uam;
//
//import cn.itbox.diq.common.util.JacksonUtils;
//import cn.itbox.gis.common.base.util.gis.CoordUtil;
//import cn.itbox.gis.common.utils.DateUtils;
//import cn.itbox.gis.common.vo.CoordinateSegment;
//import com.mapbox.geojson.Point;
//import com.mapbox.turf.TurfConstants;
//import com.mapbox.turf.TurfMeasurement;
//import org.json.JSONArray;
//import org.locationtech.jts.geom.Coordinate;
//import org.locationtech.jts.geom.LineSegment;
//
//import java.text.ParseException;
//import java.util.*;
//
//public class 确定时间戳v2 {
//    public static void main(String[] args) throws ParseException {
//        String str01="[[112.991936, 28.251097, 0, [], 1720538160000], [112.991999, 28.249999, 0, [], 1720538160000], [112.993999, 28.247999, 0, [], 1720538166000], [112.993999, 28.245999, 0, [], 1720538180000], [112.993999, 28.243999, 0, [], 1720538191000], [112.993999, 28.241999, 0, [], 1720538202000], [112.993999, 28.239999, 0, [], 1720538213000], [112.993999, 28.237999, 0, [], 1720538224000], [112.995999, 28.235999, 0, [], 1720538235000], [112.996999, 28.234999, 0, [], 1720538249000], [112.995999, 28.233999, 0, [], 1720538256000], [112.995755, 28.233755, 0, [], 1720538263000], [112.99576, 28.233751, 0, [], 1720538264000], [112.99576, 28.233751, 0, [], 1720538264000]]";
//        String str02="[[112.99576, 28.233751, 0, [], 1720538160000], [112.995999, 28.233999, 0, [], 1720538160000], [112.996999, 28.234999, 0, [], 1720538161000], [112.995999, 28.235999, 0, [], 1720538168000], [112.993999, 28.237999, 0, [], 1720538175000], [112.993999, 28.239999, 0, [], 1720538189000], [112.993999, 28.241999, 0, [], 1720538200000], [112.993999, 28.243999, 0, [], 1720538211000], [112.993999, 28.245999, 0, [], 1720538222000], [112.993999, 28.247999, 0, [], 1720538233000], [112.991999, 28.249999, 0, [], 1720538244000], [112.991999, 28.251097, 0, [], 1720538258000], [112.991936, 28.251097, 0, [], 1720538264000], [112.991936, 28.251097, 0, [], 1720538264000]]";
//
//        JSONArray jsonArray01=new JSONArray(str01);
//        JSONArray jsonArray02=new JSONArray(str02);
//
//        Map<String, LineSegment> dataO1Map= getLineSegmentMap(jsonArray01,1);
//
////        System.out.println(jsonArray01.length());
//        System.out.println(""+jsonArray02.length());
//
////        for (int i = 0; i < jsonArray01.length(); i++) {
////            JSONArray jsonArray=jsonArray01.getJSONArray(i);
////            String str= DateUtils.format(new Date(jsonArray.getLong(4)));
////            System.out.println("0001====="+str);
////        }
//
//        List<UamDataModelV2> list=new ArrayList<>(1024);
//        for (int i = 3; i < jsonArray02.length()-2; i++) {
//            JSONArray jsonArray0=jsonArray02.getJSONArray(i);
//            long time=jsonArray0.getLong(4);
//            JSONArray jsonArray1=jsonArray02.getJSONArray(i+1);
//            long time2=jsonArray1.getLong(4);
//            int min= (int) (time2-time)/1000;
//
//            //距离
//            String startPoint=jsonArray0.getDouble(0)+","+jsonArray0.getDouble(1);
//            String startPoint2=jsonArray1.getDouble(0)+","+jsonArray1.getDouble(1);
//            double dis= CoordUtil.pointDistance(startPoint,startPoint2);
//
//            //夹角
//            Point currPoint = Point.fromLngLat(jsonArray0.getDouble(0), jsonArray0.getDouble(1));
//            Point nextPoint = Point.fromLngLat(jsonArray1.getDouble(0), jsonArray1.getDouble(1));
//            double angle = TurfMeasurement.bearing(currPoint,nextPoint);
//            System.out.println("距离："+dis+", 每秒距离："+(dis/min) +"  时间："+min+",夹角："+angle+" \n");
//
//            double lon=jsonArray0.getDouble(0);
//            double lat=jsonArray0.getDouble(1);
//
//
////            public UamDataModelV2(double lonNow, double latNow, long time,
////            int indexNow, int indexNext,
////            double lonNext, double latNext) {
//
//
//            UamDataModelV2 dataModelV2= new  UamDataModelV2(jsonArray0.getDouble(0),jsonArray0.getDouble(1),time,i,i+1,jsonArray1.getDouble(0),jsonArray1.getDouble(1));
//            double minDistance=(dis/min);
//            //计算时间点
//            list.add(dataModelV2);
//
//            //每秒计算一个时间点
//            for(int h=0;h<min-1;h++){
//                long tempTime=list.get(list.size()-1).time+1000;
//                list.add(new  UamDataModelV2(jsonArray0.getDouble(0),jsonArray0.getDouble(1),tempTime,i,i+1,jsonArray1.getDouble(0),jsonArray1.getDouble(1)));
//            }
//        }
//
//        Map<String, LineSegment> dataInfo =   getLineSegmentMap(list);
//
//        dataO1Map.keySet().forEach(a->{
//
//            if(dataInfo.containsKey(a)){
////
////                System.out.println(a+"  "+dataInfo.get(a).toString());
//
//                Coordinate g=dataO1Map.get(a).intersection(dataInfo.get(a));
//                if(g != null) {
//                    System.out.println(a+"---"+dataInfo.get(a).getCoordinate(0)+" "+dataInfo.get(a).getCoordinate(1));
//                    System.out.println(dataO1Map.get(a).getCoordinate(0) + " " + dataO1Map.get(a).getCoordinate(1));
//                    System.out.println();
//                }
//            }
//        });
//    }
//    private static  void point(UamDataModelV2 uamDataModelInfo){
//        System.out.println(DateUtils.format(new Date(uamDataModelInfo.getTime()))+"    "  +JacksonUtils.objToStr(uamDataModelInfo));
//    }
//
//    private static Map<String, LineSegment> getLineSegmentMap(List<UamDataModelV2> points) throws ParseException {
//        Map<String, LineSegment> map = new LinkedHashMap<>();
//        int row = points.size();
//        for (int i = 0; i < row ; i++) {
//            UamDataModelV2 one = points.get(i);
//            CoordinateSegment coordinateOne = new CoordinateSegment(one.getLonNow(), one.getLatNow(), one.getIndexNow(), new Date(one.getTime()));
//            CoordinateSegment coordinateTwo = new CoordinateSegment(one.getLonNext(), one.getLatNext(), one.getIndexNext(), new Date(one.getTime()));
//            LineSegment lineStringSegment = new LineSegment(coordinateOne, coordinateTwo);
//            map.put(DateUtils.format(coordinateOne.getTime()), lineStringSegment);
//        }
//        return map;
//    }
//
//    private static Map<String, LineSegment> getLineSegmentMap(JSONArray points, int j) throws ParseException {
//        Map<String, LineSegment> map = new LinkedHashMap<>();
//        int row = points.length();
//        for (int i = j; i < row - j; i++) {
//            JSONArray one = points.getJSONArray(i);
//            JSONArray two = points.getJSONArray(i + 1);
//            CoordinateSegment coordinateOne = new CoordinateSegment(one.getDouble(0), one.getDouble(1), i, new Date(one.getLong(4)));
//            CoordinateSegment coordinateTwo = new CoordinateSegment(two.getDouble(0), two.getDouble(1), i + 1, new Date(one.getLong(4)));
//            LineSegment lineStringSegment = new LineSegment(coordinateOne, coordinateTwo);
//            map.put(DateUtils.format(coordinateOne.getTime()), lineStringSegment);
//        }
//        return map;
//    }
//}
